package com.bwie.controller;

import com.bwie.pojo.TbItem;
import com.bwie.service.TbItemService;
import com.bwie.service.TbTypeService;
import com.bwie.utils.R;
import com.bwie.vo.ReviewDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @Author:Max
 * @Date: 2024/8/9 19:00
 * @Description
 **/
@RestController
@RequestMapping("/user/item")
public class ItemController {

    @Autowired
    TbItemService tbItemService;

    @Autowired
    TbTypeService tbTypeService;

    @PostMapping("/listType")
    public R listType(){
        return tbTypeService.listType();
    }

    /**
     * 图片上传
     * @param
     * @return
     */
    @PostMapping("/imageUpload")
  public R imageUpload(@RequestPart("file") MultipartFile file) throws IOException {
        return tbTypeService.imageUpload(file);
    }
    //**添加item表
    @PostMapping("/addItemList")
    public R addItemList(@RequestBody TbItem tbItem){
     return tbTypeService.addItemList(tbItem);
    }

    @PostMapping("/itemList")
    public R itemList(){
        return tbTypeService.itemList();
    }


    /**
     * 提交初审结果
     */
    @PostMapping("/review")
    public R submitReview(@RequestBody ReviewDTO dto) {

        return   tbItemService.submitReview(dto);
    }
}
